package com.eugenes.design.cardvalidator;

import com.eugenes.design.Card;
import com.eugenes.util.date.DateTimeValidator;
import org.joda.time.DateTime;

public class DateTimeCardValidator implements CardValidator {

    private DateTimeValidator dateTimeValidator;

    public DateTimeCardValidator(DateTimeValidator dateTimeValidator) {
        ifNullThrowIllegalArgException(dateTimeValidator);
        this.dateTimeValidator = dateTimeValidator;
    }

    private void ifNullThrowIllegalArgException(Object obj) {
        if (obj == null) {
            throw new IllegalArgumentException("Argument is null.");
        }
    }

    @Override
    public boolean validate(Card /* ignore */ card) {
        ifNullThrowIllegalArgException(card);
        DateTime dateTime = new DateTime();
        return dateTimeValidator.isValid(dateTime);
    }

    @Override
    public void cardIsUsed(Card /* ignore */ card) {
        ifNullThrowIllegalArgException(card);
    }
}
